package net.kesumu.general.android.animation;

import android.support.v4.view.ViewPager;
import android.view.View;

public class FadeInOutPageTransformer implements ViewPager.PageTransformer{
    public FadeInOutPageTransformer() {
    }

    @Override
    public void transformPage(View view, float position) {
        if (position < -1) { // [-Infinity,-1)
            // This page is way off-screen to the left.
            view.setAlpha(0);

        } else if (position <= 0) {
            view.setAlpha(1f + position);
        } else if (position <= 1) { // [-1,1]
            view.setAlpha(1f - position);
        } else { // (1,+Infinity]
            // This page is way off-screen to the right.
            view.setAlpha(0);
        }
    }

}
